CFLAGS = -Wall -g -c -nostdlib
all:clean interupt.c start.S drv/LedDrv.c drv/NandDrv.c drv/UartDrv.c main.c common/commlib.c common/eventQueue.c drv/KeyDrv.c drv/PmwDrv.c music.c common/timer.c
	arm-linux-gcc $(CFLAGS) -o interupt.o interupt.c -Idrv -I. -Icommon
	arm-linux-gcc $(CFLAGS) -o LedDrv.o drv/LedDrv.c -Idrv
	arm-linux-gcc $(CFLAGS) -o start.o start.S -Idrv
	arm-linux-gcc $(CFLAGS) -o NandDrv.o drv/NandDrv.c -Idrv
	arm-linux-gcc $(CFLAGS) -o sub_start.o sub_start.c -Idrv -I.
	arm-linux-gcc $(CFLAGS) -o UartDrv.o drv/UartDrv.c -Idrv -I. -Icommon
	arm-linux-gcc $(CFLAGS) -o KeyDrv.o drv/KeyDrv.c -Idrv -I. -Icommon
	@arm-linux-gcc $(CFLAGS) -c -g -o SonarDrv.o drv/SonarDrv.c -Idrv -I. -Icommon
	arm-linux-gcc $(CFLAGS) -o PmwDrv.o drv/PmwDrv.c -Idrv -I. -Icommon
	arm-linux-gcc $(CFLAGS) -o commlib.o common/commlib.c
	arm-linux-gcc $(CFLAGS) -o eventQueue.o common/eventQueue.c
	arm-linux-gcc $(CFLAGS) -o timer.o common/timer.c -Icommon -I.
	arm-linux-gcc $(CFLAGS) -o main.o main.c -Idrv -Icommon
	arm-linux-gcc $(CFLAGS) -o music.o music.c -Idrv -Icommon
	arm-linux-gcc $(CFLAGS) -o dumb.o dumb.c -Idrv	
	arm-linux-ld -T nand.lds -o nand.elf start.o sub_start.o LedDrv.o interupt.o UartDrv.o main.o commlib.o eventQueue.o KeyDrv.o PmwDrv.o music.o timer.o SonarDrv.o
	arm-linux-objcopy -O binary nand.elf nand.bin
	arm-linux-objdump -D -m arm nand.elf > nand.dis
	rm -rf *.o

clean:
	rm -rf *.o *.elf *.bin *.dis *~
